unit EditGridColumn;

interface

uses
  Winapi.Windows,Winapi.Messages, SysUtils, Variants, Classes, Graphics,
  Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses,
  uniGUIClasses, uniGUIForm, uniLabel, jpeg, uniGUIBaseClasses, uniImage,
  uniButton, uniBitBtn, uniBasicGrid, uniDBGrid, DB, DBClient, ClientRowSet,
  Clipbrd;

type
  TFrmEditGridColumn = class(TUniForm)
    UniImage8: TUniImage;
    lbCaption: TUniLabel;
    gridBill: TUniDBGrid;
    btSave: TUniBitBtn;
    btClose: TUniBitBtn;
    dsColumn: TDataSource;
    crsBasColumn: TClientRowSet;
    crsBasColumnCOLUMN_ID: TStringField;
    crsBasColumnFIELD_NAME: TStringField;
    crsBasColumnFIELD_INDEX: TIntegerField;
    crsBasColumnCOLUMN_TYPE: TStringField;
    crsBasColumnLIST_SOURCE: TStringField;
    crsBasColumnALIGNMENT: TStringField;
    crsBasColumnEDITOR: TStringField;
    crsBasColumnTITLE: TStringField;
    crsBasColumnWIDTH: TIntegerField;
    crsBasColumnFONTCOLOR: TStringField;
    crsBasColumnTABLENAME: TStringField;
    crsBasColumnMODULE_NAME: TStringField;
    crsBasColumnGROUP_CODE: TStringField;
    crsBasColumnSYS_ACCOUNT: TStringField;
    crsBasColumnVISIBLE: TIntegerField;
    crsBasColumnVISIBLE_CAP: TStringField;
    crsBasColumnUPDATETIME: TStringField;
    crsBasColumnVERSION: TIntegerField;
    procedure btSaveClick(Sender: TObject);
    procedure btCloseClick(Sender: TObject);
    procedure UniFormShow(Sender: TObject);
    procedure gridBillColumnSort(Column: TUniDBGridColumn; Direction: Boolean);
    procedure gridBillCellClick(Column: TUniDBGridColumn);
    procedure gridBillDblClick(Sender: TObject);
    procedure UniFormCreate(Sender: TObject);
  private
    { Private declarations }
    currField: TField;
  public
    { Public declarations }
    TableName:String;
    ModuleName:String;
  end;

function FrmEditGridColumn: TFrmEditGridColumn;

implementation

{$R *.dfm}

uses
  MainModule, uniGUIApplication,toolmodule,expmodule, uCommFunction;

function FrmEditGridColumn: TFrmEditGridColumn;
begin
  Result := TFrmEditGridColumn(UniMainModule.GetFormInstance(TFrmEditGridColumn));
end;

procedure TFrmEditGridColumn.btCloseClick(Sender: TObject);
begin
  dmTool.crsColumn.CancelUpdates;
  self.Close;
end;

procedure TFrmEditGridColumn.btSaveClick(Sender: TObject);
begin
  dmTool.crsColumn.ApplyUpdates;
  self.Close;
end;





procedure TFrmEditGridColumn.gridBillCellClick(Column: TUniDBGridColumn);
begin
  currField := Column.Field;
end;

procedure TFrmEditGridColumn.gridBillColumnSort(Column: TUniDBGridColumn;
  Direction: Boolean);
begin
  SortColumn((gridBill.DataSource.DataSet as TClientRowSet), Column.FieldName, Direction);
end;

procedure TFrmEditGridColumn.gridBillDblClick(Sender: TObject);
begin
  if currField <> nil then
    Clipboard.AsText := currField.AsString;
end;

procedure TFrmEditGridColumn.UniFormCreate(Sender: TObject);
begin
  SetCompoentLanguage(Self);
end;

procedure TFrmEditGridColumn.UniFormShow(Sender: TObject);
begin
  if dsColumn.DataSet.RecordCount = 0 then
  begin
    dmtool.RefeshColumnInfo(self.TableName,self.ModuleName);
  end;
  SetFieldsSort(gridBill);
  currField := nil;
end;

end.
